import { createSSRApp } from 'vue'
import pinia from './stores'
import App from './App.vue'

//第二步，入口文件里注册插件：
import CustomHook from 'spa-custom-hooks'
const diyHooks = {
  UserInfo: {
    name: 'UserInfo',
    watchKey: ['userinfo'],
    deep: true,
    onUpdate(val: any) {
      //userinfo里的nickName非空则表示命中此钩子
      return !!val.nickName
    },
  },
}

//1.vue架构的注册方式
export function createApp() {
  const app = createSSRApp(App)
  app.use(pinia)
  app.use(CustomHook, diyHooks, pinia)
  return {
    app,
  }
}
